Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing large arrays with JS values into Wasm detaching memory #4353

Merged
merged 1 commit into from
Dec 15, 2024

Conversation

daxpedda
Copy link
Collaborator

@daxpedda daxpedda commented Dec 14, 2024

When passing arrays with JS values from JS to Wasm we have to insert each entry into the reference type table. Each insertion can cause allocation, which invalidates the memory buffer and throws.

This PR fixes it by getting a new memory view after every insertion. This will likely degrade performance especially when passing large arrays. To fix this we have to find a way to pass a larger set of reference values without having to call into Rust each time.

Fixes #4352.

@daxpedda daxpedda changed the title Fix passing large arrays into Rust detaching memory Fix passing large arrays with JS values into Rust detaching memory Dec 14, 2024
@daxpedda daxpedda changed the title Fix passing large arrays with JS values into Rust detaching memory Fix passing large arrays with JS values into Wasm detaching memory Dec 14, 2024
@daxpedda daxpedda force-pushed the js-to-wasm-detached branch 2 times, most recently from 382ce52 to 5a68cbd Compare December 14, 2024 17:22
@daxpedda daxpedda force-pushed the js-to-wasm-detached branch from 5a68cbd to f4660ef Compare December 14, 2024 17:36
@daxpedda daxpedda merged commit 033e50a into rustwasm:main Dec 15, 2024
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using exported Rust structs causes detached Buffer issue
1 participant